class Storage {
  public set(data: Partial<StorageData>) {
    let key: StorageKey = ''
    for (key in data) {
      const d = data[key]
      localStorage.setItem(key, JSON.stringify(d))
    }
  }

  public get<K extends StorageKey>(
    keys: K[]
  ) {
    const res: Pick<StorageData, K> = {} as any
    for (const key of keys) {
      res[key] = JSON.parse(localStorage.getItem(key as string)!) as K
    }
    return res
  }
}

export let storage = new Storage()
